<?php
declare (strict_types=1);

namespace app\service;

use app\traits\ServiceTrait;
use think\facade\Db;


/**
 * 菜单
 * Class ClientService
 * @package app\service
 * @author  2066362155@qq.com
 */
class MenuService
{
    
    use ServiceTrait;

    /**
     * @param $field
     * @return array
     */
    public static function queryListPage($param)
    {
        $where = ['enable' => 1,'is_del' => 0];

        $condition = $param['condition'];

//         condition[menu_name]: 系统
// condition[menu_type]: 
// condition[parent_id]: 


        if (!empty($condition)) {
            // if($condition['menu_name']){
            //     $where['menu_name'] = $condition['menu_name'];
            // }
            $menuList = Db::table('sys_menu')
                        ->field('id,menu_name as menuName,menu_type as menuType,iconcls,sort_no as sortNo,request,permission')
                        ->where($where)->paginate(['page' => $param['page'], 'list_rows' => $param['pageSize']])
                        ->toArray();
        } else {
   
            $menuList = Db::table('sys_menu')
                        ->field('id,menu_name as menuName,menu_type as menuType,iconcls,sort_no as sortNo,request,permission')
                        ->where($where)->paginate(['page' => $param['page'], 'list_rows' => $param['pageSize']])
                        ->toArray();
        }

        return $menuList;
    }

   
}

